import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import welcome from '@/components/welcome.vue';
import Login from '@/components/login.vue'
import menu from '@/components/menu.vue'
import index from '@/components/index.vue';
import goods from '@/components/goods.vue';
import category from '@/components/category.vue';
import spec from '@/components/spec.vue';
import evaluate from '@/components/evaluate.vue';
import deploy from '@/components/deploy.vue';
import addgoods from '@/components/addgoods.vue';
import seckgoods from '@/components/seckgoods.vue';
import bargaingoods from '@/components/bargaingoods.vue';
import bargain from '@/components/bargain.vue';
import addlive from '@/components/live/addlive.vue';
import livelist from '@/components/live/livelist.vue';
import groupgoods from '@/components/groupbuy/groupgoods.vue';
import grouplist from '@/components/groupbuy/grouplist.vue';

Vue.use(Router)

//cv以下代码解决路由地址重复的报错问题(一劳永逸)
const originalReplace = Router.prototype.replace
Router.prototype.replace = function replace (location) {
  return originalReplace.call(this, location).catch(err => err)
}//解决路由重复报错问题

export default new Router({
  routes: [
    {
      path: '/',
      name: 'index',
      component: index,
      hidden: true
  }, {
      path: '/login',
      name: 'Login',
      component: Login,
      hidden: true
  },
    {
      path: '/menu',
      name: 'menu',
      component: menu,
      hidden: true,
      children:[
        {
          path: '/welcome',
          name: 'welcome',
          component: welcome,
        },
        {
          path: '/index',
          name: 'index',
          component: index,
        },
        {
          path: '/goods',
          name: 'goods',
          component: goods,
        },
        {
          path: '/category',
          name: 'category',
          component: category,
        },
        {
          path: '/spec',
          name: 'spec',
          component: spec,
        },
         {
          path: '/evaluate',
          name: 'evaluate',
          component: evaluate,
        },
         {
          path: '/deploy',
          name: 'deploy', 
          component: deploy,
        },
         {
          path: '/addgoods',
          name: 'addgoods', 
          component: addgoods,
          },
        {
          path: '/seckgoods',
          name: 'seckgoods', 
          component: seckgoods,
        },
        {
          path: '/bargaingoods',
          name: 'bargaingoods', 
          component: bargaingoods,
        },
        {
          path: '/bargain',
          name: 'bargain', 
          component: bargain,
        },
        {
          path: '/addlive',
          name: 'addlive', 
          component: addlive,
        },
        {
          path: '/livelist',
          name: 'livelist', 
          component: livelist,
        },
        {
          path: '/groupgoods',
          name: 'groupgoods', 
          component: groupgoods,
        },
        {
          path: '/grouplist',
          name: 'grouplist', 
          component: grouplist,
        },
      ]
    },
   
  ]
})
